// 管理员--持久层
var mongoose = require('mongoose');

//注册
const reg = async (admin) => {
   return await mongoose.model("admins").create(admin);
    // await
};

//登录
const login = async ({ adminName, adminPassword }) =>  {
    return await mongoose.model("admins").find({ adminName, adminPassword });
    // await
};

//验证用户名
const isUse = async ({ adminName }) => {
    return await mongoose.model("admins").countDocuments({ adminName })
    // await
};

module.exports = {reg,login,isUse}